package com.yyoo.doc.html.tag;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author zzy
 * 支持的 html 标签
 */
public abstract class HtmlTag {

    private HtmlTag() {
    }

    public static final String LINK = "link";

    public static final String STYLE = "style";

    public static final String P = "p";

    public static final String SPAN = "span";

    public static final String DIV = "div";

    public static final String H1 = "h1";

    public static final String H2 = "h2";

    public static final String H3 = "h3";

    public static final String H4 = "h4";

    public static final String H5 = "h5";

    public static final String H6 = "h6";

    public static final String TABLE = "table";
    public static final String TR = "tr";
    public static final String TD = "td";
    public static final String TH = "th";
    public static final String THEAD = "thead";
    public static final String TBODY = "tbody";

    public static final String IMG = "img";
    public static final String UL = "ul";
    public static final String OL = "ol";
    public static final String LI = "li";

    /**
     * 自定义的 new-page 标签，用于强制分页
     * 请放在 body 标签内，不要有子标签
     */
    public static final String PAGE_NEW = "page-new";

    /**
     * 自定义的 new-header 标签，用于页眉生成
     * 请放在 body 标签内，可以包含子标签
     */
    public static final String PAGE_HEADER = "page-header";

    /**
     * 自定义的 new-footer 标签，用于页脚生成
     * 请放在 body 标签内，可以包含子标签
     */
    public static final String PAGE_FOOTER = "page-footer";

    /**
     * 块级元素文本标签
     */
    public static final List<String> BLOCK_TEXT_TAGS = Stream.of(P, DIV, H1, H2, H3, H4, H5, H6).collect(Collectors.toList());

    /**
     * 行级元素文本标签
     */
    public static final List<String> TEXT_TAGS = Collections.singletonList(SPAN);

    /**
     * 列表标签
     */
    public static final List<String> LIST_TAGS = Stream.of(UL, OL, LI).collect(Collectors.toList());

    /**
     * 表格单元格标签
     */
    public static final List<String> TABLE_CELL_TAGS = Stream.of(TD, TH).collect(Collectors.toList());

    /**
     * 返回当前标签是否跳过解析
     * @param tagName
     * @return
     */
    public static boolean isIgnoreTag(String tagName) {
        return !(LINK.equals(tagName) || STYLE.equals(tagName)
                || PAGE_NEW.equals(tagName) || PAGE_HEADER.equals(tagName)
                || PAGE_FOOTER.equals(tagName) || IMG.equals(tagName) || TABLE.equals(tagName)
                || TEXT_TAGS.contains(tagName)
                || BLOCK_TEXT_TAGS.contains(tagName) || TABLE_CELL_TAGS.contains(tagName)
                || LIST_TAGS.contains(tagName));
    }

}
